﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Outlook;

namespace WhiteBook.Outlook
{
    public class API
    {
        public static List<ContactItem> ReadContacts()
        {
            List<ContactItem> ci = new List<ContactItem>();
            Application app = new ApplicationClass();
            NameSpace ns = app.GetNamespace("MAPI");
            MAPIFolder contacts = ns.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
            foreach (Object o in contacts.Items)
            {
                if (o is ContactItem)
                {
                    ContactItem c = (ContactItem)o;
                    ci.Add(c);
                }
            }
            ns.Logoff();
            return ci;
        }
    }
}
